﻿Shader "Custom/NoLightTexture" {
Properties {
		_MainTex ("Base (RGB)", 2D) = "white" {}
		_MatCap ("Color", 2D) = "white" {}
	}
	SubShader {
		Tags { 
			"RenderType"="Opaque"
		}
		LOD 200
		Lighting Off
		Fog { Mode Off }
		Offset -1, -1
		Blend SrcAlpha OneMinusSrcAlpha
		
		Pass
		{
			CGPROGRAM
			#pragma vertex vert
			#pragma fragment frag			
			#include "UnityCG.cginc"
			struct appdata_t
			{
				float4 vertex : POSITION;
				float2 texcoord : TEXCOORD0;
			};			
			struct v2f
            {
                float4 pos    : SV_POSITION;
                float2 uv     : TEXCOORD0;
                float2 cap    : TEXCOORD1;
            };
            uniform float4 _MainTex_ST;            
            v2f vert (appdata_base v)
            {
                v2f o;
                o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
                o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
                
                half2 capCoord;
                capCoord.x = dot(UNITY_MATRIX_IT_MV[0].xyz,v.normal);
                capCoord.y = dot(UNITY_MATRIX_IT_MV[1].xyz,v.normal);
                o.cap = capCoord * 0.5 + 0.5;
                
                return o;
            }
            
            uniform sampler2D _MainTex;
            uniform sampler2D _MatCap;
            
            fixed4 frag (v2f i) : COLOR
            {
                fixed4 tex = tex2D(_MainTex, i.uv);
                fixed4 mc = tex2D(_MatCap, i.cap);
                
                return (tex + (mc*2.0)-1.0);
            }
			ENDCG
		}
	} 
	FallBack "Diffuse"
}

